/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import DTO.usuarioDTO;
import DTO.tasacionGarantiaHipoDTO;
import DAO.garantiasDAO;
import DTO.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;

/**
 *
 * @author Luis Olave 10
 */
public class ModificacionRelacionGarantiaOperacion extends javax.swing.JFrame {

    usuarioDTO user;
    garantiasDAO reg = new garantiasDAO();
    String auxNombre = "";
    relacionGarantiaOperacionHipoDTO RelHipo;
    relacionGarantiaOperacionAutoDTO RelAuto;
    relacionGarantiaOperacionWarraDTO RelWarra;
    relacionGarantiaOperacionCdpDTO RelCdp;
    int id;
    
    public ModificacionRelacionGarantiaOperacion(usuarioDTO user) {
        this.user = user;
        initComponents();
        this.chkHipoRel.setSelected(true);
        this.jPanel3.setVisible(false);
        this.jPanel4.setVisible(false);
        this.jPanel5.setVisible(false);
        this.btnActualizarRel.setVisible(false);
        this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        lblLogo = new javax.swing.JLabel();
        lblIngresoGaraAuto = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel10 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        txtRolRel = new javax.swing.JTextField();
        btnBuscarPorSii = new javax.swing.JButton();
        chkHipoRel = new javax.swing.JCheckBox();
        jPanel3 = new javax.swing.JPanel();
        txtPatenteRel = new javax.swing.JTextField();
        btnBuscarPorPatente = new javax.swing.JButton();
        chkAutoRel = new javax.swing.JCheckBox();
        chkWarraRel = new javax.swing.JCheckBox();
        jPanel4 = new javax.swing.JPanel();
        txtDunRel = new javax.swing.JTextField();
        btnBuscarPorDun = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        txtNumRel = new javax.swing.JTextField();
        btnBuscarPorNumero = new javax.swing.JButton();
        chkCDPRel = new javax.swing.JCheckBox();
        pnlDatosPersoGara1 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        txtNombreRel = new javax.swing.JTextField();
        txtApellMatRel = new javax.swing.JTextField();
        txtApellPatRel = new javax.swing.JTextField();
        txtRutRel = new javax.swing.JTextField();
        btnMenuPrincipal = new javax.swing.JButton();
        jPanel12 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        pnlDescripGarantia = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtDescripcionRel = new javax.swing.JTextArea();
        lblDescripcion = new javax.swing.JLabel();
        jPanel13 = new javax.swing.JPanel();
        btnActualizarRel = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtRepertorioRel = new javax.swing.JTextField();
        txtNotariaRel = new javax.swing.JTextField();
        txtValorRel = new javax.swing.JTextField();
        txtValorImptoRel = new javax.swing.JTextField();
        jcFechaConsGta = new com.toedter.calendar.JDateChooser();
        btnMenuP1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("MODIFICACIÓN RELACIÓN GTÍA. OPERACIÓN");
        setResizable(false);

        lblLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGE/logo.JPG"))); // NOI18N

        lblIngresoGaraAuto.setFont(new java.awt.Font("Century Gothic", 1, 18)); // NOI18N
        lblIngresoGaraAuto.setText("MODIFI. RELACIÓN GARANTÍA - OPERACIÓN");

        jTabbedPane1.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INGRESE ROL SII", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        btnBuscarPorSii.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnBuscarPorSii.setText("BUSCAR");
        btnBuscarPorSii.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarPorSiiActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtRolRel)
                    .addComponent(btnBuscarPorSii, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(txtRolRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBuscarPorSii))
        );

        buttonGroup1.add(chkHipoRel);
        chkHipoRel.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        chkHipoRel.setText("HIPOTECARIA");
        chkHipoRel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkHipoRelActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INGRESE PATENTE", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        btnBuscarPorPatente.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnBuscarPorPatente.setText("BUSCAR");
        btnBuscarPorPatente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarPorPatenteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtPatenteRel)
                    .addComponent(btnBuscarPorPatente, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txtPatenteRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBuscarPorPatente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        buttonGroup1.add(chkAutoRel);
        chkAutoRel.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        chkAutoRel.setText("AUTOMOTRIZ");
        chkAutoRel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkAutoRelActionPerformed(evt);
            }
        });

        buttonGroup1.add(chkWarraRel);
        chkWarraRel.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        chkWarraRel.setText("WARRANT");
        chkWarraRel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkWarraRelActionPerformed(evt);
            }
        });

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INGRESE CÓDIGO ÚNICO (D.U.N 14)", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        btnBuscarPorDun.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnBuscarPorDun.setText("BUSCAR");
        btnBuscarPorDun.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarPorDunActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnBuscarPorDun, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtDunRel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(41, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(txtDunRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBuscarPorDun))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INGRESE NÚMERO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        btnBuscarPorNumero.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnBuscarPorNumero.setText("BUSCAR");
        btnBuscarPorNumero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarPorNumeroActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(txtNumRel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btnBuscarPorNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txtNumRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnBuscarPorNumero))
        );

        buttonGroup1.add(chkCDPRel);
        chkCDPRel.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        chkCDPRel.setText("CDP");
        chkCDPRel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkCDPRelActionPerformed(evt);
            }
        });

        pnlDatosPersoGara1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS PERSONALES GARANTE", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        jLabel36.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel36.setText("RUT");

        jLabel37.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel37.setText("APELLIDO PATERNO");

        jLabel39.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel39.setText("APELLIDO MATERNO");

        jLabel40.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel40.setText("NOMBRE");

        txtNombreRel.setBackground(new java.awt.Color(255, 255, 102));
        txtNombreRel.setDisabledTextColor(new java.awt.Color(0, 0, 204));
        txtNombreRel.setEnabled(false);

        txtApellMatRel.setBackground(new java.awt.Color(255, 255, 102));
        txtApellMatRel.setDisabledTextColor(new java.awt.Color(0, 0, 204));
        txtApellMatRel.setEnabled(false);

        txtApellPatRel.setBackground(new java.awt.Color(255, 255, 102));
        txtApellPatRel.setDisabledTextColor(new java.awt.Color(0, 0, 204));
        txtApellPatRel.setEnabled(false);

        txtRutRel.setBackground(new java.awt.Color(255, 255, 102));
        txtRutRel.setDisabledTextColor(new java.awt.Color(0, 0, 204));
        txtRutRel.setEnabled(false);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel37)
                    .addComponent(jLabel36))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtRutRel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtApellPatRel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 113, Short.MAX_VALUE)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel39)
                    .addComponent(jLabel40))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtNombreRel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtApellMatRel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(196, 196, 196))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel36)
                    .addComponent(txtRutRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel40)
                    .addComponent(txtNombreRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel37)
                    .addComponent(txtApellPatRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel39)
                    .addComponent(txtApellMatRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout pnlDatosPersoGara1Layout = new javax.swing.GroupLayout(pnlDatosPersoGara1);
        pnlDatosPersoGara1.setLayout(pnlDatosPersoGara1Layout);
        pnlDatosPersoGara1Layout.setHorizontalGroup(
            pnlDatosPersoGara1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPersoGara1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlDatosPersoGara1Layout.setVerticalGroup(
            pnlDatosPersoGara1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlDatosPersoGara1Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        btnMenuPrincipal.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnMenuPrincipal.setText("MENÚ PRINCIPAL");
        btnMenuPrincipal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMenuPrincipalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlDatosPersoGara1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(chkHipoRel)
                                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(chkAutoRel)
                                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(26, 26, 26)
                                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(chkWarraRel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(chkCDPRel)
                                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(btnMenuPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chkHipoRel)
                    .addComponent(chkAutoRel)
                    .addComponent(chkWarraRel)
                    .addComponent(chkCDPRel))
                .addGap(18, 18, 18)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(52, 52, 52)
                .addComponent(pnlDatosPersoGara1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
                .addComponent(btnMenuPrincipal)
                .addGap(65, 65, 65))
        );

        jTabbedPane1.addTab("INFO. GARANTE", jPanel10);

        pnlDescripGarantia.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DESCRIPCIÓN GARANTIA", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        txtDescripcionRel.setBackground(new java.awt.Color(255, 255, 102));
        txtDescripcionRel.setColumns(20);
        txtDescripcionRel.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        txtDescripcionRel.setRows(5);
        txtDescripcionRel.setDisabledTextColor(new java.awt.Color(0, 0, 204));
        txtDescripcionRel.setEnabled(false);
        jScrollPane4.setViewportView(txtDescripcionRel);

        lblDescripcion.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        lblDescripcion.setText("DESCRIPCIÓN");

        javax.swing.GroupLayout pnlDescripGarantiaLayout = new javax.swing.GroupLayout(pnlDescripGarantia);
        pnlDescripGarantia.setLayout(pnlDescripGarantiaLayout);
        pnlDescripGarantiaLayout.setHorizontalGroup(
            pnlDescripGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDescripGarantiaLayout.createSequentialGroup()
                .addGap(70, 70, 70)
                .addComponent(lblDescripcion)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlDescripGarantiaLayout.setVerticalGroup(
            pnlDescripGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlDescripGarantiaLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(pnlDescripGarantiaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblDescripcion)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(367, 367, 367))
        );

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlDescripGarantia, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlDescripGarantia, javax.swing.GroupLayout.PREFERRED_SIZE, 359, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(68, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 835, Short.MAX_VALUE)
            .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel12Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 469, Short.MAX_VALUE)
            .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel12Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(20, 20, 20)))
        );

        jTabbedPane1.addTab("DESCRIP. GARANTÍA", jPanel12);

        btnActualizarRel.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnActualizarRel.setText("ACTUALIZAR");
        btnActualizarRel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnActualizarRelActionPerformed(evt);
            }
        });

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "MODIFI. RELACIÓN GTÍA. OPERACIÓN", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        jLabel2.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel2.setText("VALOR OPERACIÓN");

        jLabel3.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel3.setText("FECHA CONSTITUCIÓN GTÍA.");

        jLabel4.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel4.setText("NOTARÍA");

        jLabel5.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel5.setText("REPERTORIO");

        jLabel6.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel6.setText("VALOR IMPTO. TIMBRES ESTAMP.");

        txtValorRel.setBackground(new java.awt.Color(255, 255, 102));
        txtValorRel.setDisabledTextColor(new java.awt.Color(0, 0, 204));
        txtValorRel.setEnabled(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addGap(40, 40, 40))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(18, 18, 18)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtValorRel)
                    .addComponent(txtValorImptoRel, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                    .addComponent(jcFechaConsGta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 184, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtRepertorioRel, javax.swing.GroupLayout.DEFAULT_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNotariaRel, javax.swing.GroupLayout.DEFAULT_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNotariaRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtRepertorioRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(txtValorRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jcFechaConsGta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtValorImptoRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))))
                .addContainerGap(229, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        btnMenuP1.setText("MENÚ PRINCIPAL");
        btnMenuP1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMenuP1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addGap(0, 372, Short.MAX_VALUE)
                        .addComponent(btnActualizarRel)
                        .addGap(190, 190, 190)
                        .addComponent(btnMenuP1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnMenuP1)
                    .addComponent(btnActualizarRel))
                .addGap(64, 64, 64))
        );

        jTabbedPane1.addTab("MODIFI. RELACIÓN GTÍA. - OPERACÍON", jPanel13);

        jLabel1.setText("MENÚ PRINCIPAL\\MODIFICAIÓN RELACIÓN GARANTÍA OPERACIÓN");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblLogo)
                .addGap(114, 114, 114)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblIngresoGaraAuto)
                    .addComponent(jLabel1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 840, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblIngresoGaraAuto)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel1))
                    .addComponent(lblLogo))
                .addGap(18, 18, 18)
                .addComponent(jTabbedPane1))
        );

        setSize(new java.awt.Dimension(856, 640));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btnMenuPrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMenuPrincipalActionPerformed
        MenuPrincipal venMenuPrincipal = new MenuPrincipal(user);
        venMenuPrincipal.setVisible(true);
        ModificacionRelacionGarantiaOperacion.this.dispose();
    }//GEN-LAST:event_btnMenuPrincipalActionPerformed

    private void btnBuscarPorSiiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarPorSiiActionPerformed
        try
        {
        garantiaHipotecariaDTO estado = reg.buscarPorRol(this.txtRolRel.getText().trim());
        if(estado.getEstado_hipo().equals("Eliminada"))
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Estado Garantía Eliminada");
            this.txtRolRel.setText(null);
            this.txtPatenteRel.setText(null);
            this.txtDunRel.setText(null);
            this.txtNumRel.setText(null);
            limpiar2();
        }
        else
        {
        if (this.txtRolRel.getText().length() == 0) // validamos campos vacios
            {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese un Rol valido");
            this.txtRolRel.setText(null);
            this.txtPatenteRel.setText(null);
            this.txtDunRel.setText(null);
            this.txtNumRel.setText(null);
            limpiar2();
            
            }
         else{
            RelHipo = reg.BuscarRelacionOperacionHipo(this.txtRolRel.getText().trim());
            if(RelHipo.getId_gara_ope() == 0)
            {
                javax.swing.JOptionPane.showMessageDialog(this, "Garantia no encontrada");
                this.txtRolRel.setText(null);
                this.txtPatenteRel.setText(null);
                this.txtDunRel.setText(null);
                this.txtNumRel.setText(null);
                limpiar2();
            
            }else{
            this.txtRutRel.setText(RelHipo.getHipo().getRut_gara_hipo());
            this.txtApellPatRel.setText(RelHipo.getHipo().getApell_paterno_hipo());
            this.txtApellMatRel.setText(RelHipo.getHipo().getApell_materno_hipo());
            this.txtNombreRel.setText(RelHipo.getHipo().getNombre_hipo());
            this.txtDescripcionRel.setText(RelHipo.getHipo().getDescrip_hipo());
            this.txtValorRel.setText(String.valueOf(RelHipo.getValor_opera_gara_ope()));
            this.txtValorImptoRel.setText(String.valueOf(RelHipo.getValor_impto_tim_gara_ope()));
            this.txtNotariaRel.setText(RelHipo.getNotaria_gara_ope());
            this.txtRepertorioRel.setText(RelHipo.getRepert_gara_ope());
            Date aux = DTO.ConversionFechas.convertToDate(RelHipo.getFech_consti_gara_ope());
            this.jcFechaConsGta.setDate(aux);
            btnActualizarRel.setVisible(true);
            
            this.txtPatenteRel.setText(null);
            this.txtDunRel.setText(null);
            this.txtNumRel.setText(null);
            auxNombre = "Hipotecaria";
            id=RelHipo.getId_gara_ope();
            }
            }
        }}catch(Exception e)
        {
            e.getMessage();
        }
    }//GEN-LAST:event_btnBuscarPorSiiActionPerformed

    private void btnBuscarPorPatenteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarPorPatenteActionPerformed
        try
        {
        garantiaAutomotrizDTO estado = reg.buscarPorPatente(this.txtPatenteRel.getText().trim());
        if(estado.getEstado_auto().equals("Eliminada"))
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Estado Garantía Eliminada");
            this.txtRolRel.setText(null);
            this.txtPatenteRel.setText(null);
            this.txtDunRel.setText(null);
            this.txtNumRel.setText(null);
            limpiar2();
        }
        else
        {
        if(this.txtPatenteRel.getText().length() == 0)
            {
                javax.swing.JOptionPane.showMessageDialog(this, "Ingrese una Patente valida");
                this.txtRolRel.setText(null);
                this.txtPatenteRel.setText(null);
                this.txtDunRel.setText(null);
                this.txtNumRel.setText(null);
                limpiar2();
            }
        else{
            RelAuto = reg.BuscarRelacionOperacionAuto(this.txtPatenteRel.getText().trim());
            if(RelAuto.getId_gara_ope() == 0)
            {
                javax.swing.JOptionPane.showMessageDialog(this, "Garantia no encontrada!");
                this.txtRolRel.setText(null);
                this.txtPatenteRel.setText(null);
                this.txtDunRel.setText(null);
                this.txtNumRel.setText(null);
                limpiar2();
            
            }else{
            this.txtRutRel.setText(RelAuto.getAuto().getRut_gara_auto());
            this.txtApellPatRel.setText(RelAuto.getAuto().getApell_paterno_auto());
            this.txtApellMatRel.setText(RelAuto.getAuto().getApell_materno_auto());
//            this.txtFolioGarRel.setText(String.valueOf(RelAuto.getAuto().getFolio_garantia_auto()));
            this.txtNombreRel.setText(RelAuto.getAuto().getNombre_auto());
            this.txtDescripcionRel.setText(RelAuto.getAuto().getDescrip_auto());
            this.txtValorRel.setText(String.valueOf(RelAuto.getValor_opera_gara_ope()));
            this.txtValorImptoRel.setText(String.valueOf(RelAuto.getValor_impto_tim_gara_ope()));
            this.txtNotariaRel.setText(RelAuto.getNotaria_gara_ope());
            this.txtRepertorioRel.setText(RelAuto.getRepert_gara_ope());
            Date aux = DTO.ConversionFechas.convertToDate(RelAuto.getFech_consti_gara_ope());
            this.jcFechaConsGta.setDate(aux);
            btnActualizarRel.setVisible(true);
            this.txtRolRel.setText(null);
            
            this.txtDunRel.setText(null);
            this.txtNumRel.setText(null);
            auxNombre = "Automotriz";
            id=RelAuto.getId_gara_ope();
            }
            }}}catch(Exception e)
            {
                e.getMessage();
            }
    }//GEN-LAST:event_btnBuscarPorPatenteActionPerformed

    private void btnBuscarPorDunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarPorDunActionPerformed
        
        try
        {
        garantiaWarrantsDTO estado = reg.buscarPorDUN(this.txtDunRel.getText().trim());
        if(estado.getEstado_warra().equals("Eliminada"))
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Estado Garantía Eliminada");
            this.txtRolRel.setText(null);
            this.txtPatenteRel.setText(null);
            this.txtDunRel.setText(null);
            this.txtNumRel.setText(null);
            limpiar2();
        }
        else
        {
        if(this.txtDunRel.getText().length() == 0)
            {
                javax.swing.JOptionPane.showMessageDialog(this, "Ingrese un DUN valido");
                this.txtRolRel.setText(null);
                this.txtPatenteRel.setText(null);
                this.txtDunRel.setText(null);
                this.txtNumRel.setText(null);
                limpiar2();
            }
        else{
            RelWarra = reg.BuscarRelacionOperacionWarra(this.txtDunRel.getText().trim());
            if(RelWarra.getId_gara_ope() == 0)
            {
                javax.swing.JOptionPane.showMessageDialog(this, "Garantia no encontrada");
                this.txtRolRel.setText(null);
                this.txtPatenteRel.setText(null);
                this.txtDunRel.setText(null);
                this.txtNumRel.setText(null); 
                limpiar2();
            
            }else{
            this.txtRutRel.setText(RelWarra.getWarra().getRut_garante_warra());
            this.txtApellPatRel.setText(RelWarra.getWarra().getApell_paterno_warra());
            this.txtApellMatRel.setText(RelWarra.getWarra().getApell_materno_warra());
//            this.txtFolioGarRel.setText(String.valueOf(RelWarra.getWarra().getFolio_warra()));
            this.txtNombreRel.setText(RelWarra.getWarra().getNombre_warra());
            this.txtDescripcionRel.setText(RelWarra.getWarra().getDescrip_warra());
            this.txtValorRel.setText(String.valueOf(RelWarra.getValor_opera_gara_ope()));
            this.txtValorImptoRel.setText(String.valueOf(RelWarra.getValor_impto_tim_gara_ope()));
            this.txtNotariaRel.setText(RelWarra.getNotaria_gara_ope());
            this.txtRepertorioRel.setText(RelWarra.getRepert_gara_ope());
            Date aux = DTO.ConversionFechas.convertToDate(RelWarra.getFech_consti_gara_ope());
            this.jcFechaConsGta.setDate(aux);
            btnActualizarRel.setVisible(true);
            this.txtRolRel.setText(null);
            this.txtPatenteRel.setText(null);
          
            this.txtNumRel.setText(null);
            auxNombre = "Warrant";
            id=RelWarra.getId_gara_ope();
            }
        }}}catch(Exception e)
        {
            e.getMessage();
        }
    }//GEN-LAST:event_btnBuscarPorDunActionPerformed

    private void btnBuscarPorNumeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarPorNumeroActionPerformed
        
        try
        {
        garantiaCdpOtrosDTO estado = reg.buscarPorNum(Integer.parseInt(this.txtNumRel.getText().trim()));
        if(estado.getEstado_cdp().equals("Eliminada"))
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Estado Garantía Eliminada");
            this.txtRolRel.setText(null);
            this.txtPatenteRel.setText(null);
            this.txtDunRel.setText(null);
            this.txtNumRel.setText(null);
            limpiar2();
        }
        else
        {
        if (!this.txtNumRel.getText().matches("[ 0-9]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo números");
            this.txtRolRel.setText(null);
                this.txtPatenteRel.setText(null);
                this.txtDunRel.setText(null);
                this.txtNumRel.setText(null);
                limpiar2();
        }
        else
        {
        if(this.txtNumRel.getText().length() == 0)
            {
                javax.swing.JOptionPane.showMessageDialog(this, "Ingrese un Numero valido");
                this.txtRolRel.setText(null);
                this.txtPatenteRel.setText(null);
                this.txtDunRel.setText(null);
                this.txtNumRel.setText(null);
                limpiar2();
            
            }
        else{
            RelCdp = reg.BuscarRelacionOperacionCdp(Integer.parseInt(this.txtNumRel.getText().trim()));
            if(RelCdp.getId_gara_ope() == 0)
            {
                javax.swing.JOptionPane.showMessageDialog(this, "Garantia No Encontrada");
                this.txtRolRel.setText(null);
                this.txtPatenteRel.setText(null);
                this.txtDunRel.setText(null);
                this.txtNumRel.setText(null);
                limpiar2();
            
            }else{
            this.txtRutRel.setText(RelCdp.getCdp().getRut_gara_cdp());
            this.txtApellPatRel.setText(RelCdp.getCdp().getApell_paterno_cdp());
            this.txtApellMatRel.setText(RelCdp.getCdp().getApell_materno_cdp());
//            this.txtFolioGarRel.setText(String.valueOf(RelCdp.getCdp().getFolio_cdp()));
            this.txtNombreRel.setText(RelCdp.getCdp().getNombre_cdp());
            this.txtDescripcionRel.setText(RelCdp.getCdp().getDescrip_cdp());
            this.txtValorRel.setText(String.valueOf(RelCdp.getValor_opera_gara_ope()));
            this.txtValorImptoRel.setText(String.valueOf(RelCdp.getValor_impto_tim_gara_ope()));
            this.txtNotariaRel.setText(RelCdp.getNotaria_gara_ope());
            this.txtRepertorioRel.setText(RelCdp.getRepert_gara_ope());
            Date aux = DTO.ConversionFechas.convertToDate(RelCdp.getFech_consti_gara_ope());
            this.jcFechaConsGta.setDate(aux);
            btnActualizarRel.setVisible(true);
            this.txtRolRel.setText(null);
            this.txtPatenteRel.setText(null);
            this.txtDunRel.setText(null);
            
            auxNombre = "CDP";
            id=RelCdp.getId_gara_ope();
            }
        }}}}catch(Exception e)
        {
            e.getMessage();
        }
    }//GEN-LAST:event_btnBuscarPorNumeroActionPerformed

    private void btnActualizarRelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualizarRelActionPerformed
         switch(auxNombre)
        {
            case "Hipotecaria":
                if (!txtValorImptoRel.getText().equals("")) {
                    RelHipo.setValor_impto_tim_gara_ope(Integer.parseInt(txtValorImptoRel.getText().trim()));
                }
                if (!txtNotariaRel.getText().equals("")) {
                    RelHipo.setNotaria_gara_ope(txtNotariaRel.getText().trim());
                }
                if (!txtRepertorioRel.getText().equals("")) {
                    RelHipo.setRepert_gara_ope(txtRepertorioRel.getText().trim());
                } 
                RelHipo.setFech_consti_gara_ope(new SimpleDateFormat("dd/MM/yyyy").format(jcFechaConsGta.getDate()));
                RelHipo.setId_gara_ope(id);
                int respuesta = javax.swing.JOptionPane.showConfirmDialog(null, "Se grabara la Relacion Garantia:", "Operacion", JOptionPane.OK_CANCEL_OPTION);
                if (respuesta == 0) {
                    reg.modificacionRelOperacionGarantiaHipo(RelHipo);
                    javax.swing.JOptionPane.showMessageDialog(null, "Actualizacion Exitosa!");
                    limpiar2();
                   }
                else
                {
                    
                }
                break;
                 case "Automotriz":
                if (!txtValorImptoRel.getText().equals("")) {
                    RelAuto.setValor_impto_tim_gara_ope(Integer.parseInt(txtValorImptoRel.getText().trim()));
                }
                if (!txtNotariaRel.getText().equals("")) {
                    RelAuto.setNotaria_gara_ope(txtNotariaRel.getText().trim());
                }
                if (!txtRepertorioRel.getText().equals("")) {
                    RelAuto.setRepert_gara_ope(txtRepertorioRel.getText().trim());
                } 
                RelAuto.setFech_consti_gara_ope(new SimpleDateFormat("dd/MM/yyyy").format(jcFechaConsGta.getDate()));
                RelAuto.setId_gara_ope(id);
                int respuesta2 = javax.swing.JOptionPane.showConfirmDialog(null,  "Se grabara la Relacion Garantia:", "Operacion", JOptionPane.OK_CANCEL_OPTION);
                if (respuesta2 == 0) {
                    reg.modificacionRelOperacionGarantiaAuto(RelAuto);
                    javax.swing.JOptionPane.showMessageDialog(null, "Actualizacion Exitosa!");
                    limpiar2();
                   }
                else
                {
                    
                }
                break;
                 case "Warrant":
                if (!txtValorImptoRel.getText().equals("")) {
                    RelWarra.setValor_impto_tim_gara_ope(Integer.parseInt(txtValorImptoRel.getText().trim()));
                }
                if (!txtNotariaRel.getText().equals("")) {
                    RelWarra.setNotaria_gara_ope(txtNotariaRel.getText().trim());
                }
                if (!txtRepertorioRel.getText().equals("")) {
                    RelWarra.setRepert_gara_ope(txtRepertorioRel.getText().trim());
                } 
                RelWarra.setFech_consti_gara_ope(new SimpleDateFormat("dd/MM/yyyy").format(jcFechaConsGta.getDate()));
                RelWarra.setId_gara_ope(id);
                int respuesta3 = javax.swing.JOptionPane.showConfirmDialog(null,  "Se grabara la Relacion Garantia:", "Operacion", JOptionPane.OK_CANCEL_OPTION);
                if (respuesta3 == 0) {
                    reg.modificacionRelOperacionGarantiaWarra(RelWarra);
                    javax.swing.JOptionPane.showMessageDialog(null, "Actualizacion Exitosa!");
                    limpiar2();
                   }
                else
                {
                    
                }
                break;     
                
                case "CDP":
                if (!txtValorImptoRel.getText().equals("")) {
                    RelCdp.setValor_impto_tim_gara_ope(Integer.parseInt(txtValorImptoRel.getText().trim()));
                }
                if (!txtNotariaRel.getText().equals("")) {
                    RelCdp.setNotaria_gara_ope(txtNotariaRel.getText().trim());
                }
                if (!txtRepertorioRel.getText().equals("")) {
                    RelCdp.setRepert_gara_ope(txtRepertorioRel.getText().trim());
                } 
                RelCdp.setFech_consti_gara_ope(new SimpleDateFormat("dd/MM/yyyy").format(jcFechaConsGta.getDate()));
                RelCdp.setId_gara_ope(id);
                int respuesta4 = javax.swing.JOptionPane.showConfirmDialog(null,  "Se grabara la Relacion Garantia:", "Operacion", JOptionPane.OK_CANCEL_OPTION);
                if (respuesta4 == 0) {
                    reg.modificacionRelOperacionGarantiaCDP(RelCdp);
                    javax.swing.JOptionPane.showMessageDialog(null, "Actualizacion Exitosa!");
                    limpiar2();
                   }
                else
                {
                    
                }
                break; 
         }
        
    }//GEN-LAST:event_btnActualizarRelActionPerformed

    private void btnMenuP1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMenuP1ActionPerformed
        MenuPrincipal venMenuPrincipal = new MenuPrincipal(user);
        venMenuPrincipal.setVisible(true);
        ModificacionRelacionGarantiaOperacion.this.dispose();
    }//GEN-LAST:event_btnMenuP1ActionPerformed

    private void chkHipoRelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkHipoRelActionPerformed
        if(this.chkHipoRel.isSelected())
        {
            jPanel2.setVisible(true);
            jPanel3.setVisible(false);
            jPanel4.setVisible(false);
            jPanel5.setVisible(false);
        }
    }//GEN-LAST:event_chkHipoRelActionPerformed

    private void chkAutoRelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkAutoRelActionPerformed
        if(this.chkAutoRel.isSelected())
        {
            jPanel2.setVisible(false);
            jPanel3.setVisible(true);
            jPanel4.setVisible(false);
            jPanel5.setVisible(false);
        }
    }//GEN-LAST:event_chkAutoRelActionPerformed

    private void chkWarraRelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkWarraRelActionPerformed
       if(this.chkWarraRel.isSelected())
       {
            jPanel2.setVisible(false);
            jPanel3.setVisible(false);
            jPanel4.setVisible(true);
            jPanel5.setVisible(false);
       }
    }//GEN-LAST:event_chkWarraRelActionPerformed

    private void chkCDPRelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkCDPRelActionPerformed
        if(this.chkCDPRel.isSelected())
        {
            jPanel2.setVisible(false);
            jPanel3.setVisible(false);
            jPanel4.setVisible(false);
            jPanel5.setVisible(true);
        }
    }//GEN-LAST:event_chkCDPRelActionPerformed
    
    
    
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /*
//         * Set the Nimbus look and feel
//         */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /*
//         * If Nimbus (introduced in Java SE 6) is not available, stay with the
//         * default look and feel. For details see
//         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(ModificacionRelacionGarantiaOperacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(ModificacionRelacionGarantiaOperacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(ModificacionRelacionGarantiaOperacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(ModificacionRelacionGarantiaOperacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /*
//         * Create and display the form
//         */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new ModificacionRelacionGarantiaOperacion().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnActualizarRel;
    private javax.swing.JButton btnBuscarPorDun;
    private javax.swing.JButton btnBuscarPorNumero;
    private javax.swing.JButton btnBuscarPorPatente;
    private javax.swing.JButton btnBuscarPorSii;
    private javax.swing.JButton btnMenuP1;
    private javax.swing.JButton btnMenuPrincipal;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JCheckBox chkAutoRel;
    private javax.swing.JCheckBox chkCDPRel;
    private javax.swing.JCheckBox chkHipoRel;
    private javax.swing.JCheckBox chkWarraRel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private com.toedter.calendar.JDateChooser jcFechaConsGta;
    private javax.swing.JLabel lblDescripcion;
    private javax.swing.JLabel lblIngresoGaraAuto;
    private javax.swing.JLabel lblLogo;
    private javax.swing.JPanel pnlDatosPersoGara1;
    private javax.swing.JPanel pnlDescripGarantia;
    private javax.swing.JTextField txtApellMatRel;
    private javax.swing.JTextField txtApellPatRel;
    private javax.swing.JTextArea txtDescripcionRel;
    private javax.swing.JTextField txtDunRel;
    private javax.swing.JTextField txtNombreRel;
    private javax.swing.JTextField txtNotariaRel;
    private javax.swing.JTextField txtNumRel;
    private javax.swing.JTextField txtPatenteRel;
    private javax.swing.JTextField txtRepertorioRel;
    private javax.swing.JTextField txtRolRel;
    private javax.swing.JTextField txtRutRel;
    private javax.swing.JTextField txtValorImptoRel;
    private javax.swing.JTextField txtValorRel;
    // End of variables declaration//GEN-END:variables

    private void limpiar2() {
            this.txtRutRel.setText(null);
            this.txtApellPatRel.setText(null);
            this.txtApellMatRel.setText(null);
//            this.txtFolioGarRel.setText(null);
            this.txtNombreRel.setText(null);
            this.txtDescripcionRel.setText(null);
            this.txtValorRel.setText(null);
            this.txtValorImptoRel.setText(null);
            this.txtNotariaRel.setText(null);
            this.txtRepertorioRel.setText(null);
            this.jcFechaConsGta.setCalendar(null);
            this.btnActualizarRel.setVisible(false);
    }
}
